{/* Copyright 2025 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License. */}

import {Layout} from '../../src/Layout';
export default Layout;
import docs from 'docs:@react-aria/ssr';
import {FunctionAPI} from '../../src/FunctionAPI';

export const section = 'Utilities';
export const description = 'Returns whether the app is currently in server-side rendering or hydration.';

# useIsSSR

<PageDescription>{docs.exports.useIsSSR.description}</PageDescription>

## Introduction

`useIsSSR` returns `true` during server rendering and hydration, and updates to `false`
immediately after hydration. This can be used to ensure that the server rendered HTML
and initially hydrated DOM match, but trigger an additional render after hydration to
run browser-specific code. For example, it could be used to run media queries or feature
detection for browser-specific APIs that affect rendering but cannot be run server side.

In React 16 and 17, this hook must be used in combination with the [SSRProvider](SSRProvider) component
wrapping your application.

## Example

```tsx
import {useIsSSR} from 'react-aria';

function MyComponent() {
  let isSSR = useIsSSR();
  return <span>{isSSR ? 'Server' : 'Client'}</span>;
}
```

## API

<FunctionAPI function={docs.exports.useIsSSR} links={docs.links} />
